/*
 * Copyright 2007-2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.ymate.platform.serv.nio.server;

import java.io.IOException;

/**
 * @author 刘镇 (suninformation@163.com) on 2022/6/5 00:57
 * @since 2.1.2
 */
public abstract class AbstractNioSessionListener<SESSION_WRAPPER extends NioSessionWrapper, MESSAGE_TYPE> implements INioSessionListener<SESSION_WRAPPER, MESSAGE_TYPE> {

    @Override
    public void onSessionIdleRemoved(SESSION_WRAPPER sessionWrapper) {
    }

    @Override
    public void onSessionRegistered(SESSION_WRAPPER session) throws IOException {
    }

    @Override
    public void onSessionAccepted(SESSION_WRAPPER session) throws IOException {
    }

    @Override
    public void onBeforeSessionClosed(SESSION_WRAPPER session) throws IOException {
    }

    @Override
    public void onAfterSessionClosed(SESSION_WRAPPER session) throws IOException {
    }

    @Override
    public void onMessageReceived(MESSAGE_TYPE message, SESSION_WRAPPER session) throws IOException {
    }

    @Override
    public void onExceptionCaught(Throwable e, SESSION_WRAPPER session) throws IOException {
        if (e instanceof IOException) {
            throw (IOException) e;
        } else {
            throw new IOException(e.getMessage(), e);
        }
    }
}
